import $http from '@/utils/http'
import { put,takeEvery,call } from 'redux-saga/effects'
import {LOADALLLIST,GETALLLIST,LOADTHEME,GETTHEME,LOADSERIES,GETSERIES} from './actionTypes'

function* foo(){
    let list =yield call($http.get,{
        url:'Categroydetail.json'
    })
    let theme =yield call($http.get,{
        url:'theme.json'
    })
    // console.log(theme);
    let series =yield call($http.get,{
        url:'series.json'
    })

    yield put({
        type:LOADALLLIST,
        alllist:list.data.data.list
    })

    yield put({
        type:LOADTHEME,
        theme:theme.data.data.list
    })
    yield put({
        type:LOADSERIES,
        series:series.data.data.list
    })
}

function* saga(){
    yield takeEvery(GETALLLIST,foo)
    yield takeEvery(GETTHEME,foo)
    yield takeEvery(GETSERIES,foo)
}


export default saga